$(document).ready(function() {
      
      function doAjaxNewLead() {

      $.ajax({
        url: site_url + 'admin/leads/get_new_leads',
        type: 'GET',
        dataType: 'html'
      })
      .done(function (response, textStatus, jqXHR){

        console.log("response: " + response);
        if(response != 0){
          
          new Audio(base_url + 'assets/sound_effect/notify_new_lead.mp3').play();
          $("#leads").prepend(response);
		  
          jQuery("abbr.timeago").timeago();
        }// end if
      })
      .fail(function (response, textStatus, jqXHR){

        console.log('error notify-new-status');
      })
      .always(function (response, textStatus, jqXHR){

        setTimeout(doAjaxNewLead, 20000);
      });

    }
   
    doAjaxNewLead();
  });